package com.skzh.flightplans.utils;

import lombok.Data;

/**
 * TaskStatus 类用于表示任务的状态
 *
 * taskId: 任务ID
 * status: 任务状态 (PROCESSING, SUCCESS, FAILED)
 * message: 任务失败时的错误信息
 * result: 任务成功时的结果
 */
@Data
public class TaskStatus {
    private String taskId;
    private String status; // PROCESSING, SUCCESS, FAILED
    private String message;
    private Object result;

    public TaskStatus(String taskId) {
        this.taskId = taskId;
        this.status = "PROCESSING";
    }

    // 创建处理中的任务
    public static TaskStatus createProcessing(String taskId) {
        return new TaskStatus(taskId);
    }

    // 创建成功完成的任务
    public static TaskStatus createSuccess(String taskId, Object result) {
        TaskStatus status = new TaskStatus(taskId);
        status.setStatus("SUCCESS");
        status.setResult(result);
        return status;
    }

    // 创建失败的任务
    public static TaskStatus createFailed(String taskId, String message) {
        TaskStatus status = new TaskStatus(taskId);
        status.setStatus("FAILED");
        status.setMessage(message);
        return status;
    }
}